package com.xyc.rabbitmq.service;

import com.xyc.rabbitmq.bean.Book;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

@Service
public class BookService {
    @RabbitListener(queues = "xyc.news") // 可以监听多个队列
    public void receive(Book book) {
        System.out.println("收到消息" + book);
    }

    @RabbitListener(queues = "xyc")
    public void receive02(Message msg) {
        System.out.println(msg.getBody());
        System.out.println(msg.getMessageProperties());
    }
}
